package com.jason.www.dao;

import com.jason.www.domain.OrderDetail;
import org.apache.ibatis.jdbc.SQL;

public class OrderDetailSqlProvider {

    public String insertSelective(OrderDetail record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("order_detail");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }
        
        if (record.getOrdersId() != null) {
            sql.VALUES("orders_id", "#{ordersId,jdbcType=BIGINT}");
        }
        
        if (record.getItemsId() != null) {
            sql.VALUES("items_id", "#{itemsId,jdbcType=BIGINT}");
        }
        
        if (record.getItemsNum() != null) {
            sql.VALUES("items_num", "#{itemsNum,jdbcType=INTEGER}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(OrderDetail record) {
        SQL sql = new SQL();
        sql.UPDATE("order_detail");
        
        if (record.getOrdersId() != null) {
            sql.SET("orders_id = #{ordersId,jdbcType=BIGINT}");
        }
        
        if (record.getItemsId() != null) {
            sql.SET("items_id = #{itemsId,jdbcType=BIGINT}");
        }
        
        if (record.getItemsNum() != null) {
            sql.SET("items_num = #{itemsNum,jdbcType=INTEGER}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}